package xps.and.uudaijia.userclient.view.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.jude.utils.JUtils;

import java.util.List;

import rx.Subscriber;
import xps.and.uudaijia.userclient.adapter.YHJAdapterDaijia;
import xps.and.uudaijia.userclient.data.baen.YHJBean;
import xps.and.uudaijia.userclient.data.net.UserNetWorks;
import xps.and.uudaijia.userclient.util.ListDividerItemDecoration;
import xps.and.uudaijia.userclient.view.base.BaseSwipeRefreshFragment;
import xps.and.uudaijia.userclient.view.base.BaseSwipeRefreshFragmentYHJ;

public class YHJDaijiaFragment extends BaseSwipeRefreshFragmentYHJ {
    String userId;

    @Override
    protected void getData(int pageIndex) {
        int page = pageIndex + 1;
    }

    @Override
    public void onRefresh() {
        super.onRefresh();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        ListDividerItemDecoration list = new ListDividerItemDecoration((int) (1 * getActivity().getResources().getDisplayMetrics().density));
        recyclerView.addItemDecoration(list);
        setRefreshEnable(false);
        abstractRecyclerAdapter = new YHJAdapterDaijia(activity, recyclerView);
        abstractRecyclerAdapter.setAutoLoadMoreEnable(true);
        super.onActivityCreated(savedInstanceState);
        douserId();
    }

    void douserId() {
        userId = JUtils.getSharedPreference().getString("User_ID", "");
        UserNetWorks.getYHJ("1", new Subscriber<YHJBean>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(YHJBean yhjBean) {
                List<YHJBean.ReturnBodyBean> list = yhjBean.getReturn_body();
                if (list != null && list.size() <= 0) {
                    onFail("没有更多");
                    return;
                }
                adapterListData = list;
                onResponce();
            }
        });
    }
}
